<h1>เอกสารวิชาการ</h1>
<div class="search">
	<form method="get">
		<table class="form">
			<tr><th>หัวข้อ</th><td><input type="text" name="search" value="<?php echo (isset($_GET['search']))?$_GET['search']:'' ?>" /></td><th>หมวดหมู่</th><td><?php echo form_dropdown('category_id',$documents->category->get_option(),@$_GET['category_id'],'','ทั้งหมด') ?></td><td><input type="submit" value="ค้นหา" /></td></tr>
		</table>
	</form>
</div>

<?php echo $documents->pagination()?>
<table class="list">
	<tr>
		<th width="70">แสดง</th>
		<th>เริ่มวันที่</th>
		<th>หัวข้อ</th>
		<th>โดย</th>
		<th>
			<a rel="lightbox" class="btn" href="categories/admin/categories/documents?iframe=true&width=90%&height=90%">หมวดหมู่</a>
		</th>
		<th width="90">
			<?php if(permission('documents', 'create')):?>
				<a class="btn" href="documents/admin/documents/form">เพิ่มรายการ</a>
			<?php endif;?>
		</th>
	</tr>
	<?php foreach($documents as $document): ?>
	<tr <?php echo cycle()?>>
		<td><input type="checkbox" name="status" value="<?php echo $document->id ?>" <?php echo ($document->status=="approve")?'checked="checked"':'' ?> <?php echo (@$_POST['status']=="approve")?'':'' ?> /></td>
		<td><?=DB2Date($document->start_date)?></td>
		<td><?php echo $document->title;?></td>
		<td><?php echo $document->user->display?></td>
		<td><?php echo anchor('documents/admin/documents?category_id='.$document->category_id,lang_decode($document->category->name,'th')) ?></td>
		<td>
			<?php if(permission('documents', 'update')):?>
			<a class="btn" href="documents/admin/documents/form/<?php echo $document->id?>" >แก้ไข</a> 
			<?php endif;?>
			<?php if(permission('documents', 'delete')):?>
			<a class="btn" href="documents/admin/documents/delete/<?php echo $document->id?>" onclick="return confirm('<?php echo lang('notice_confirm_delete');?>')">ลบ</a>
			<?php endif;?>
		</td>
		</tr>
		<?php endforeach; ?>
	</table>
<?php echo $documents->pagination()?>